Page({
  //列表数据
  data:{
    movies:[],
    loading:false,
    count:6,
    windowHeight:0,//初始化窗口高度
    scrollTop:100//初始化竖向滚动条位置
  },
  requestData:function(){
    const that = this
    wx.request({
    //url:'http://m.maoyan.com/movie/list.json',
      url:'https://api.douban.com/v2/movie/in_theaters',
      data:{
        count:that.data.count
      },
      header: {
      'content-type':'json'
      },
      success:function(res){
        that.setData({
          movies:res.data.subjects,
        //movies:res.data.data.movies,
          //更新数据后隐藏加载框
          loading:true
        })
      }
    })
    //获取系统信息
    wx.getSystemInfo({
      success:function(res){
        that.setData({
          windowHeight:res.windowHeight
        })
      }
    })
  },
  //页面生命周期函数--监听页面加载
  onLoad:function(){
    this.requestData();
  },
  //下拉刷新
  onPullDownRefresh:function(){
    this.setData({
      count:this.data.count + 6
    })
    this.requestData();
  },
  //购票
  buyTickets:function(){
    //显示模态弹窗
    wx.showModal({
      title:'购票提示：',
      content:'暂不支持购票功能',
      //是否显示取消按钮
      showCancel:false,
      //确认按钮的文字
      confirmText:'知道啦',
      //确认按钮的文字颜色
      confirmColor:'#ff4d64'
    })
  }
})